﻿<h2>
    JsonTest</h2>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<script type="text/javascript">
    
    
    $("form").submit(function (evt) {
        // extract values to submit   
        alert("entre");  
        var form = $(this),
            id = form.find("[name=Id]").val(),
            name = form.find("[name=Name]").val(),
            json = JSON.stringify({
                Id: id,
                Name: name
            });
        
        $.ajax({
            url: form.attr("action"),
            type: 'POST',
            contentType: 'application/json; charset=utf-8',
            dataType: 'json',
            data: json,
            success: handleLogin
        });

        // stop form submitting
        evt.preventDefault();
    });
</script>
<form method="post" action="JsonTest" id="form">
    <fieldset>
        <legend>Cordobian</legend>
       <br/>
            @Html.Label("Name")
       <br/>
            @Html.TextBox("Name")
      <br/>
            @Html.Label("Id")
       <br/>
            @Html.TextBox("Id")
      
        <br/>
            <input type="submit" value="Save" />
       
    </fieldset>
</form>
<div>
    @Html.ActionLink("Back to List", "Index")
</div>
